function ocr_callback(ocrtext){ var tb = document.getElementById("wpTextbox1"); tb.value = ocrtext; tb.disabled=false; } function add_ocr() { var tb = document.getElementById("wpTextbox1"); tb.disabled=true; var input = document.getElementById("wpOcr"); if(input) input.disabled=true; if( proofreadPageWidth <= 1024 ) thumb_url = proofreadPageViewURL; else thumb_url = proofreadPageThumbURL.replace('##WIDTH##',1024); request_url = "http://toolserver.org/~thomasv/ocr.php?url="+thumb_url+"&lang="+wgContentLanguage+"&user="+wgUserName; var scriptObj = document.createElement("script"); scriptObj.setAttribute("type", "text/javascript"); scriptObj.setAttribute("src", request_url); scriptObj.setAttribute("id", "ocr_cb"); var headLoc = document.getElementsByTagName("head").item(0); headLoc.appendChild(scriptObj); } function addOCRButton2(id,comment,source,onclick){ var tb = document.getElementById("toolbar"); if(tb){ var image = document.createElement("img"); image.width = 46; image.height = 22; image.border = 0; image.className = "mw-toolbar-editbutton"; image.style.cursor = "pointer"; image.alt = "OCR"; image.title = comment; image.src = source; image.onclick = onclick; tb.appendChild(image); } } function fraktur_ocr(){ self.wgContentLanguage = "de-f"; add_ocr(); self.wgContentLanguage = "de"; } function addOCRButton(){ if(!self.proofreadPageIsEdit) return; if(!self.proofreadPageViewURL) return; //if(wgCurRevisionId) if(self.wgDBname == "dewikisource"){ addOCRButton2("wpOcr","Normale OCR","http://upload.wikimedia.org/wikipedia/commons/e/e0/Button_ocr.png",add_ocr); addOCRButton2("wpOcr","Fraktur OCR","http://upload.wikimedia.org/wikipedia/commons/a/af/Button_Fractur_OCR.png",fraktur_ocr); } else addOCRButton2("wpOcr","Get the text by OCR","http://upload.wikimedia.org/wikipedia/commons/e/e0/Button_ocr.png",add_ocr); } if(!self.proofreadpage_disable_ocr) addOnloadHook(addOCRButton);